﻿
//$(document).ready(
$(function () {
        $(".textComplete").click(function() {
    var routeVal = $(".textComplete").attr("data-api-route");
    //var routeVal = localStorage.getItem("route");
    localStorage.removeItem("route");
            $.getJSON(routeVal,
                function(data) {
                    var autoCompleteSource = [];
                    $.each(data, function() {
                        var completeItem =
                        {
                            "id": this.Id,
                            "label": this.Name,
                            "value": this.Name
                        };
                        autoCompleteSource.push(completeItem);
                    });
                    $(".textComplete").autocomplete({
                            source: autoCompleteSource,
                            minLength: 0,
                            select: function(ui) {
                                var selValue = ui.value;
                                localStorage.setItem("suppleVal", selValue);
                                $(".textComplete").text("Блаблабла");
                                $('#modalContent').empty();
                                $('#modal-section').modal('hide');
                                alert(selValue);
                            }
                        }
                    );
                }
            );
        });
    }
)
//);